package be.one.paq.ui;

import org.vaadin.navigator7.WebApplication;
import org.vaadin.navigator7.interceptor.NavigationWarningInterceptor;
import org.vaadin.navigator7.interceptor.PageChangeListenersInterceptor;

import be.one.paq.ui.page.HomePage;
import be.one.paq.ui.page.admin.user.UserPage;
import be.one.paq.ui.page.encodage.EncodagePage;
import be.one.paq.ui.page.reporting.ReportingPage;

public class PAQWebApplication extends WebApplication {

    private PageChangeListenersInterceptor pageChangeListenerInterceptor;

    public PAQWebApplication() {
        // We need to do that in the constructor (and not later), to ensure that the init method in the ancestor has the PageTemplate and the pages.
        registerPages(new Class[] {
        		HomePage.class,
                EncodagePage.class,
                ReportingPage.class,
                UserPage.class,
        });
    }
    
    @Override
    protected void registerInterceptors() {
        // 1st interceptor to call: check if user really wanna quit.
        registerInterceptor( new NavigationWarningInterceptor() );
        registerInterceptor( pageChangeListenerInterceptor = new PageChangeListenersInterceptor() );
        super.registerInterceptors();   // Default interceptors.
    }

    public PageChangeListenersInterceptor getPageChangeListenerInterceptor() {
        return pageChangeListenerInterceptor;
    }

}
